package com.example.smartcitydemo.ui.job.fragment

import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.viewModels
import com.example.smartcity_jscs.network.ResultStates.Resource
import com.example.smartcitydemo.R
import com.example.smartcitydemo.base.BaseFragment
import com.example.smartcitydemo.databinding.FragmentResumeShowBinding
import com.example.smartcitydemo.ui.job.NewJobActivity
import com.example.smartcitydemo.viewModel.job.WorkViewModel

/**
 * @PACKAGE_NAME: com.example.smartcitydemo.ui.job.fragment
 * @NAME: Caleb.F
 * @DATE: 2021/11/19 14:20
 * @Email: 1919796283@qq.com
 */
class ResumeManagerFragment :
    BaseFragment<FragmentResumeShowBinding>(R.layout.fragment_resume_show) {
    private val workViewModel: WorkViewModel by viewModels()
    override fun initData() {

    }

    override fun initView(bindView: FragmentResumeShowBinding, savedInstanceState: Bundle?) {
        bindView.btnResumeAdd.setOnClickListener {
            val intent = Intent(bindView.root.context, NewJobActivity::class.java)
            bindView.root.context.startActivity(intent)
        }
    }

    override fun addObservers(bindView: FragmentResumeShowBinding) {
        workViewModel.personResumeData.observe(viewLifecycleOwner) {
            Log.d(TAG, "addObservers: $it")
            when (it) {
                is Resource.Success -> {
                    val get = it.data?.get(0)
                    bindView.data = get
                }

            }
        }
    }


    override fun onResume() {
        super.onResume()
        workViewModel.getResumeList()
    }


}